//
//  FourthViewController.m
//  UI_Lesson11.homework
//
//  Created by dllo on 15/11/10.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "FourthViewController.h"

@interface FourthViewController ()

@end

@implementation FourthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.tag = 1000;
    button.frame = CGRectMake(30, 80, 100, 100);
    [button setTitle:@"动画不好玩" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor colorWithRed:0.7 green:0.1 blue:0.6 alpha:1];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    

    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button1.frame = CGRectMake(230, 380, 100, 100);
    button1.tag = 2000;
    [button1 setTitle:@"动画好好玩啊" forState:UIControlStateNormal];
    button1.backgroundColor = [UIColor colorWithRed:0.7 green:0.1 blue:0.6 alpha:1];
    [self.view addSubview:button1];
    [button1 addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button2.frame = CGRectMake(240, 100, 100, 100);
    button2.tag = 3000;
    [button2 setTitle:@"动画真好玩啊" forState:UIControlStateNormal];
    button2.backgroundColor = [UIColor colorWithRed:0.7 green:0.1 blue:0.6 alpha:1];
    [self.view addSubview:button2];
    [button2 addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button3.frame = CGRectMake(30, 400, 100, 100);
    button3.tag = 4000;
    [button3 setTitle:@"动画太好玩了啊" forState:UIControlStateNormal];
    button3.backgroundColor = [UIColor colorWithRed:0.7 green:0.1 blue:0.6 alpha:1];
    [self.view addSubview:button3];
    [button3 addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}

- (void)button:(UIButton *)button
{
    
    if (button.tag == 1000) {
        
        [UIView animateWithDuration:1.0 animations:^{
            
            [UIView setAnimationRepeatAutoreverses:YES];
            
            
            [UIView setAnimationRepeatCount:5];
            
            
            [UIView setAnimationCurve:UIViewAnimationCurveLinear];
            
            [UIView setAnimationDelay:1];
            
            button.frame = CGRectMake(200, 300, 60, 60);
            
        }];
        
    } else if (button.tag == 2000){
        
        [UIView animateWithDuration:1.0 animations:^{
            
            button.alpha = 0;
            button.transform = CGAffineTransformRotate(button.transform, M_PI);
            
            
            
        } completion:^(BOOL finished) {
            
            NSLog(@"动画已经结束");
            
        }];
        
    } else if (button.tag == 3000){
        
        [UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
            
            button.center = CGPointMake(300, 400);
            
        } completion:^(BOOL finished) {
            
        }];
    
    [UIView animateWithDuration:1.0 delay:0 usingSpringWithDamping:0.1 initialSpringVelocity:5 options:UIViewAnimationOptionCurveLinear animations:^{
        
        button.frame = CGRectMake(100, 400, 90, 60);
        
    } completion:^(BOOL finished) {
        
    }];
    
    
    }else{
    
 
        [UIView transitionWithView:button duration:1 options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
        button.frame = CGRectMake(200, 550, 90, 60);
        
        
    } completion:^(BOOL finished) {
        
    }];
    }
    
    
    
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
